function getInnerTextByClass(clazz, root) {
    var elements = root.getElementsByClassName(clazz);
    if (elements.length > 0) {
        return elements[0].innerText;
    }
    return "";
}

function getAttributeByTag(attribute, tag, root) {
    var elements = root.getElementsByTagName(tag);
    if (elements.length > 0 && elements[0].hasAttribute(attribute)) {
        return elements[0].getAttribute(attribute);
    }
    return "";
}

function saveToFile(fileName) {
    var json = {
        fileName: fileName,
        content: "<html>" + document.head.outerHTML + document.body.outerHTML + "<html/>"
    };
    console.log(json);
    window.JsBridge.callNative("onSaveFile", JSON.stringify(json));
}

function fetchUrl(url) {
    fetch(url)
        .then(response => response.text())
        .then(data => {
            return data
        })
        .catch(error => {
            console.log(error);
        });
    return "";
}